<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
 	String path = request.getContextPath();
 	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
 	request.setAttribute("path", path);
 	request.setAttribute("jsPath", path+"/js");
 	request.setAttribute("cssPath", path+"/css");
 	request.setAttribute("imagePath", path+"/image");
 %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="renderer" content="webkit">

    <title>DEmo</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link href="/css/bootstrap.min.css?v=3.4.0" rel="stylesheet">
    <link href="/css/font-awesome.css?v=4.3.0" rel="stylesheet">

	<link href="/css/animate.css" rel="stylesheet">
	<link href="/css/style.css?v=2.2.0" rel="stylesheet">
    <link href="/css/newTable/bootstrap-table.css" rel="stylesheet">
    <link href="/css/newTable/bootstrap-table.min.css" rel="stylesheet">
    <script src="/js/jquery.min.js"></script>
	<script src="/js/bootstrap.min.js"></script>
	<script src="/js/bootstrap-table.js"></script>
	<script src="/js/bootstrap-table-zh-CN.js"></script>
	<script type="text/javascript" src="/plugs/paging/js/jquery.pagination.js"></script>
	<script type="text/javascript">
	
	
	$(function(){
	$("#btn_print").click(function(){
		 var delArray=[];
		 var ids=$.map($('#table').bootstrapTable('getSelections'),function(row){
			delArray.push(row.sysId);
			alert(delArray);
		});
		 $.ajax({
				type:"post",
				url:"<%=basePath %>Sysrole/del",
				data:{"datas":delArray},
				cache: false,
				success:function(data){
					window.location.href="<%=basePath %>Sysrole/show";
				}
			})

	});
	<%-- function del(){
		var delArray=[];
		$("input[name=select]:checked").each(function(){
			delArray.push($(this).val());
		});
		$.ajax({
			type:"post",
			url:"<%=basePath %>Sysrole/del",
			data:{"dat":delArray},
			success:function(data){
				alert(1);
				$("#pageNum").val(1);
				$('#userSearchForm').submit();
			}
		}) --%>
		$("#table").on("click-row.bs.table",function(e,row,ele){
			var data=row.sysId;
			var temp="";
			 $.ajax({
				type:"post",
				dataType:"json",
				url:"<%=basePath %>Sysrole/list",
				data:{"SysRoleId":data},
				success:function(data){
					if(data.length>0){

						 for(i=0;i<data.length;i++){
							temp+="<tr><td>"+JSON.stringify(data[i].sysName)+"</td><td>"+JSON.stringify(data[i].funName)+"</td><td><a href='<%=basePath %>Sysrole/delRoleAuthority?RoleAuthorityId="+JSON.stringify(data[i].roleAuthorityId)+"'>删除</a></td></tr>";
						}  
					}
					
					
					$("#tbody").html(temp); 
				}
			 
			})
			 
		
			});
	
	});
	
	function showAdd(){
		$("#CreateSysrole").css("display","block");
	}
	
	function closeShowAdd(){
		$("#CreateSysrole").css("display","none");
		$("#xiugai").css("display","none");
	}
	
	function addSysrole(){
		//使用js进行表单检查
		var addName = $("#addName").val();
		if($.trim(addName)==''){
			alert("用户名不能为空");
			return;
		}
		$("#SysroleForm").submit();
	}
	
	function updateSysrole(){
		
		var updateName = $("#updateName").val();
		if($.trim(updateName)==''){
			alert("用户名不能为空");
			return;
		}
		$("#updateSysroleForm").submit();
	}
	
	</script>
	<style type="text/css">
		#XiangXi{
			margin-left:50px;
			text-align:center;
		}
		#XiangXi td{
			width:60px;
			height:25px;
		}
		#XiangXi th{
			width:60px;
			height:25px;
		}
		
		#CreateSysrole,#xiugai{
		width: 352px;
		height:400px;
		display:none;
		position:absolute;
		box-shadow:0 0 3px #000;
		top:25%;
		left:40%;
		margin-left:-50px;
		margin-top:-50px;
		z-index:500;
		background-color:white;
		border-radius:5px 5px 5px 5px;
	}
	</style>
</head>
<body>
 	  <div id="wrapper">
		
		<!-- 左边导航 -->
		<%@ include file="../share/leftMenu.jsp" %>
				
		<div id="page-wrapper" class="gray-bg dashbard-1">
		<!-- 头部 -->
		<%@ include file="../share/head.jsp" %>
	 
	 <%-- <div class="box-header">
			<form id="userSearchForm" action="<%=basePath %>Sysrole/page" method="get">
				<label>角色名：</label><input type="text" value="${sysrole.sysName }" name="sysName" id="name">
				<label>创建时间</label><input type="date" value="${sysrole.beginDate}" name="beginDate" id="begin"/>--<input type="date" name="endDate" value="${sysrole.endDate}" id="begin"/>
				<input type="hidden" id="pageNum" name="pageNum" value="${funPage.pageNo}"/> 
			    <input type="button" value="查询" onclick="search()"/>
			</form>
			
		</div> --%>
	 <div style="margin:50px;"> 
		<table id="table" data-toggle="table">
		   <thead>
		        <tr>
		        	<th data-field="check" data-checkbox="true" data-sortable="false"></th>
		            <th data-field="id">序号</th>
		            <th data-field="sysId" data-visible="false">角色ID</th>
		            <th data-field="sysName">系统角色名</th>
		            <th data-field="createDateStr">创建时间</th>
		            <th data-field="fenPeiZiYuan" data-sortable="false">分配资源</th>
		            <th data-field="XiuGai" data-sortable="false">修改系统角色</th>
		        </tr>
		    </thead>
		    <tbody>
		        <c:forEach var="s" varStatus="Status" items="${sysroleInfos }">
		        	<tr>
		        		<td></td>
		        		<td data-field-tooltip="id">${Status.index+1 }</td>
		        		<td data-field-tooltip="sysId">${s.roleId }</td>
		        		<td data-field-tooltip="sysName">${s.name }</td>
		        		<td data-field-tooltip="createDateStr">${s.createDateStr }</td>
		        		<td data-field-tooltip="fenPeiZiYuan"><a href='<%=basePath %>Sysrole/showAddBySysRoleId?roleId=${s.roleId}'>分配权限</a></td>
		        		<td data-field-tooltip="XiuGai"><input type="button" name="change" id="${s.roleId }" value="修改"></td>
		        	</tr>
		        </c:forEach>
		    </tbody>
		   
		</table>
		 <button id="btn_print" type="button" class="btn btn-default">删除数据</button>
		 <input type="button" name="addSysrole" value="添加" onclick="showAdd()">
		 </div>
		 <div id="XiangXi">
		<table border="1"><thead><tr><th>角色名</th><th>资源名</th><th>选项</th></tr></thead>
		<tbody id="tbody"></tbody></table>
	</div>
	
	<div id="CreateSysrole">
        <div style="width: 350px;height: 30px;background-image: url('../resource/image/indexImg/2017-08-07_103957.png');background-repeat: no-repeat">

        </div>
        <div style="width: 320px;height: 230px;padding: 20px">
        <h3>新增系统角色</h3>
            <form id="SysroleForm" action="<%=basePath %>Sysrole/add" method="post">
                <label>角色名称：</label><input type="text" id="addName" name="name" style="width: 230px;height: 25px"></textarea></br>
                <hr/>
                <label>允许为角色管理角色：</label><input type="text" name="mangerroleFlag" style="width: 230px;height: 25px"></textarea>
            
            <div style="text-align: center;">
            <input type="button" onclick="addSysrole()" class="save" name="save" style="margin: 5px;background: url('../resource/image/indexImg/save.png') no-repeat;width: 59px;height:26px;background-size:100%;border:0px"/>
            <input type="button" class="closeAdd" name="closeAdd" onclick="closeShowAdd()" style="margin: 5px;background: url('../resource/image/indexImg/close.png') no-repeat;width: 59px;height:26px;background-size:100%;border:0px"/>
            </div>
            </form>
        </div>

    </div>
    
    
    <div id="xiugai">
        <div style="width: 350px;height: 30px;background-image: url('../resource/image/indexImg/2017-08-07_103957.png');background-repeat: no-repeat">

        </div>
        <div style="width: 320px;height: 230px;padding: 20px">
        <h3>修改系统角色</h3>
            <form id="updateSysroleForm" action="<%=basePath %>Sysrole/update" method="post">
            	<input type="hidden" id="changeId" name="roleId"/>
                <label>角色名称：</label><input type="text" id="updateName" name="name" style="width: 230px;height: 25px"></textarea></br>
                <hr/>
                <label>允许为角色管理角色：</label><input type="text" name="mangerroleFlag" style="width: 230px;height: 25px"></textarea>
            
            <div style="text-align: center;">
            <input type="button" onclick="updateSysrole()" class="save" name="save" style="margin: 5px;background: url('../resource/image/indexImg/save.png') no-repeat;width: 59px;height:26px;background-size:100%;border:0px"/>
            <input type="button" class="closeAdd" name="closeAdd" onclick="closeShowAdd()" style="margin: 5px;background: url('../resource/image/indexImg/close.png') no-repeat;width: 59px;height:26px;background-size:100%;border:0px"/>
            </div>
            </form>
        </div>

    </div>
	</div>
	

</body>
</html>	